#ifndef _TH_LIST_H
#define _TH_LIST_H

#include <stdio.h>
#include <stdlib.h>
#include "user_threads.h"

/* A Linked-List queue implementation */

typedef struct data_t{
	uthread_id id;
	struct data_t* next;
} data_t;

typedef data_t*  data;

typedef struct t_list{
data first;
data last;
} t_list;


typedef struct t_list* tlist;

/**************************************************
tlist init():
Initializes the list.
On Failure it exits (Because of allocation error).
Returns a pointer to the initialized list.
***************************************************/
tlist init();


/**************************************************
int enqueue(tlist list,thread_id tid):
Takes a pointer to the list, and an id to be inseted
On Failure it exits (Because of allocation error).
Returns 1 on success.
***************************************************/
int enqueue(tlist list,uthread_id tid);

/**************************************************
thread_id dequeue(tlist list):
Takes a pointer to the list
Returns the first id (and moves it out of the queue)
***************************************************/
uthread_id dequeue(tlist list);

/**************************************************
void destroy(tlist list):
Takes a pointer to the list. And Destroys the ds.
***************************************************/
void destroy(tlist list);


#endif

